//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI;

namespace CommunityServer.Controls {

	internal class CollapseBarControlCollection : System.Web.UI.ControlCollection {

		public CollapseBarControlCollection( Control owner ) : base( owner ) {
		}

		public override void Add( Control child ) {
			if ( child is CollapseBarItem ) {
				base.Add( child );
				return;
			}

			if ( !( child is System.Web.UI.LiteralControl ) ) {
				throw new InvalidOperationException( String.Format( "CollapseBar can only contain controls of type CollapseBarItem. You tried to add a control of type '{0}'", child.GetType().FullName ) );
			}

		}

		public override void AddAt( int index, Control child ) {
			if ( child is CollapseBarItem ) {
				base.AddAt( index, child );
				return;
			}

			if ( !( child is LiteralControl ) ) {
				throw new InvalidOperationException( String.Format( "CollapseBar can only contain controls of type CollapseBarItem. You tried to add a control of type '{0}'", child.GetType().FullName ) );
			}

		}

	}
}
